Page({
    data: {
      notifications: [
        { id: 'adopt', label: '领养更新', enabled: true },
        { id: 'match', label: '匹配偏好', enabled: false },
        { id: 'favorite', label: '收藏更新', enabled: true },
        { id: 'security', label: '安全提醒', enabled: true },
        { id: 'event', label: '活动提醒', enabled: true },
        { id: 'shelter', label: '领养机构更新', enabled: false },
        { id: 'community', label: '社区互动', enabled: false },
        { id: 'update', label: '小程序更新', enabled: false },
        { id: 'announcement', label: '重要通知', enabled: true },
        { id: 'tips', label: '使用教程与技巧', enabled: false }
      ]
    },
  
    onToggle(e) {
      const id = e.currentTarget.dataset.id;
      const checked = e.detail.value;
  
      // 更新开关状态
      const notifications = this.data.notifications.map(item => {
        if (item.id === id) item.enabled = checked;
        return item;
      });
      this.setData({ notifications });
  
      wx.showModal({
        title: checked ? '开启提醒' : '关闭提醒',
        content: `您已${checked ? '开启' : '关闭'}“${notifications.find(n => n.id === id).label}”的消息提醒。`,
        showCancel: false
      });
    },
  
    goBack() {
      wx.navigateBack();
    }
  });
  